#define _POSIX_SOURCE
#define _BSD_SOURCE

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include "rngs.h"
#include <getopt.h>

#ifndef TEST_CASES
#define TEST_CASES 10000
#endif

#ifndef RAND_NUM
#define RAND_NUM 100
#endif

#ifndef SUPP
#define SUPP 10
#endif

int compare(const void* a, const void* b);

int test(void)
{
	int card1, card2, result, expect;

	card1 = floor(Random() * (treasure_map + 1));

	if (floor(Random() * 101) > 20) {
		card2 = floor(Random() * (treasure_map + 1));
	} else {
		card2 = card1;
	}

	if (card1 == card2) {
		expect = 0;
	} else if (card1 < card2) {
		expect = -1;
	} else { //card1 > card2
		expect = 1;
	}

	result = compare((void *) &card1, (void *) &card2);

	if (result != expect) {
		return -1;
	}

	return 0;
}

int main(int argc, char **argv)
{
	int i, result;

	for (i = 0; i < TEST_CASES; i++) {
		

		result = test(/* void */);
		if (result == 0) {
			printf("TEST CASE #%d = PASS\n", i + 1);
		} else {
			printf("TEST CASE #%d = FAIL\n", i + 1);
		}
	}

	return 0;
}